package java.single.lazy;

public class SingleLazy {
    private static SingleLazy instance;

    private SingleLazy() {
    }

    /**
     * 单例模式，避免浪费内存，但是线程不安全
     * 可以填加synchronized锁，但是加锁降低了效率
     * @author qwe
     *
     */
    private static SingleLazy getInstance() {
        if (null == instance) {
            instance = new SingleLazy();
        }
        return instance;
    }
    
    private static synchronized SingleLazy getInstance2() {
        if (null == instance) {
            instance = new SingleLazy();
        }
        return instance;
    }
    
    public void getMessage() {
        System.out.println("this is a lazy single pattern.");
    }
}
